#!/bin/bash

ARCHIVE=live.2023.01.19.tar.gz

export PATH=${PATH}:/opt/arm-hisiv300-linux/bin

export TARGET=arm-hisiv300-linux-uclibcgnueabi
export CROSS=arm-hisiv300-linux-uclibcgnueabi
export BUILD=x86_64-pc-linux-gnu

export CROSSPREFIX=${CROSS}-

export STRIP=${CROSSPREFIX}strip
export CXX=${CROSSPREFIX}g++
export CC=${CROSSPREFIX}gcc
export LD=${CROSSPREFIX}ld
export AS=${CROSSPREFIX}as
export AR=${CROSSPREFIX}ar

SCRIPT_DIR=$(cd `dirname $0` && pwd)
cd $SCRIPT_DIR

rm -rf ./_install
rm -rf ./live

# live555
if [ ! -f $ARCHIVE ]; then
    wget https://download.videolan.org/pub/contrib/live555/$ARCHIVE
fi
tar zxvf $ARCHIVE

patch -p0 < rRTSPServer.patch
patch -p0 < rRTSPServer2.patch

cd live || exit 1

./genMakefiles linux-cross
cp -f ../Makefile.rRTSPServer Makefile
cp -rf ../src .
cp -rf ../include .
